//-*- C++ -*-
/*************************************************************************
 *                                                                       *
 *  Copyright 2010, 2011 Yu Yichao                                       *
 *  yyc1992@gmail.com                                                    *
 *                                                                       *
 *  This file is part of asystem.                                        *
 *                                                                       *
 *  asystem is free software: you can redistribute it and/or modify      *
 *  it under the terms of the GNU General Public License as published by *
 *  the Free Software Foundation, either version 3 of the License, or    *
 *  (at your option) any later version.                                  *
 *                                                                       *
 *  asystem is distributed in the hope that it will be useful,           *
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
 *  GNU General Public License for more details.                         *
 *                                                                       *
 *  You should have received a copy of the GNU General Public License    *
 *  along with asystem.  If not, see <http://www.gnu.org/licenses/>.     *
 *                                                                       *
 *************************************************************************/

#ifndef _ASYSTEM_
#define _ASYSTEM_
#include <string>
#include <unistd.h>
#include <vector>
namespace asys
{
  #define SYSTEM_READ 1
  #define SYSTEM_WRITE 2
  #define SYSTEM_READERR 4
  pid_t asystem(std::string,int* read=NULL,int* wirte=NULL,int* readerr=NULL);
  int asystem(std::string,int mod,.../*read,write,readerr*/);

#define BLANK (char)0
#define VBLANK (char)-1
#define HBLANK (char)-2
  
  std::vector<std::string> cut( std::string , char=BLANK );
  bool isblank(char);
  bool isvblank(char);
  bool ishblank(char);
  std::string tr(const std::string &,char=BLANK,char=BLANK);
  int find( const std::string& , char );
  int findre( const std::string& , char );
  int find( const std::vector<std::string>& , const std::string& );
  int find( const std::string& , const std::string& );
  std::string pwd();
  int related_path( const std::string& , const std::string& );
  int in( const std::string& fullname , const std::string& path );
  inline int cd( const std::string& dir ) {return chdir( &(dir[0]) );};
  std::string getpath(const std::string&);
  std::vector<std::string> getpath(const std::vector<std::string>&);
  
  std::string getname(const std::string&);
  std::vector<std::string> getname(const std::vector<std::string>&);
}
#endif
